import { play } from '@dfeidao/animation';
import anim from '@dfeidao/atom-web/animation/anim';
import local_get from '@dfeidao/atom-web/local/get';
import local_set from '@dfeidao/atom-web/local/set';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import { IFeidaoAiBrowserComponent } from "@dfeidao/web/interfaces";
// import play from '@dfeidao/atom-web/animation/play';
export default async function a005(fd: IFeidaoAiBrowserComponent) {
	const left = fd.data.node.querySelector<HTMLDivElement>('[lefts="lefts"]');

	const icon = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-icon]');
	const right = document.getElementById('right');
	const lefts = await local_get(fd, 'lefts');
	// console.log(left, icon, right, lefts)
	// debugger
	if (lefts) {
		play(anim(left, {}, { left: { start: -200, end: 0 } }));
		play(anim(right, {}, { left: { start: 20, end: 220 } }));
		await local_set(fd, 'lefts', false);
		set_node_cls(icon, 'icon-zuo', true);
		set_node_cls(icon, 'icon-right', false);
	} else {
		play(anim(left, {}, { left: { start: 0, end: -200 } }));
		play(anim(right, {}, { left: { start: 220, end: 20 } }));
		await local_set(fd, 'lefts', true);
		set_node_cls(icon, 'icon-zuo', false);
		set_node_cls(icon, 'icon-right', true);
	}
}
